package com.itheima.reggie.service.impl;

import com.itheima.reggie.entity.SetmealDish;
import com.itheima.reggie.mapper.SetmealDishMapper;
import com.itheima.reggie.service.SetmealDishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;
@Service
public class SetmealDishServiceImpl implements SetmealDishService {
    @Autowired(required = false)
    private SetmealDishMapper setmealDishMapper;
    @Override
    public Boolean addSetmealDish(List<SetmealDish> setmealDishes) {
        for (SetmealDish setmealDish : setmealDishes) {
            setmealDish.setCreateTime(LocalDateTime.now());
            setmealDish.setUpdateTime(LocalDateTime.now());
        }
        Integer integer = setmealDishMapper.addSetmealDish(setmealDishes);
        return integer>0;
    }

    @Override
    public List<SetmealDish> findBySetmealId(Long setmealId) {
        List<SetmealDish> setmealDishes = setmealDishMapper.findBySetmealId(setmealId);
        return setmealDishes;
    }
}
